<?php
include  '../loginCheck.php';
include  '../Util.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Project</title>
    <link rel="stylesheet" type="text/css" href="view.css" media="all"/>
    <script type="text/javascript" src="view.js"></script>
    <script type="text/javascript" src="../../js/webtoolkit.aim.js"></script>

</head>
<body id="main_body" >

    <img id="top" src="top.png" alt=""/>
    <div id="form_container">

        <h1>
            <?php
            include  'menu.php';
            ?>
        </h1>
        <form id="form_144190" class="appnitro" enctype="multipart/form-data" method="post" action="../adminResolveProjects.php">
            <div class="form_description">
                <h2><a href ="projects.php">Edit Project</a> | <a href ="projectEdit.php">New Project</a> | <a href ="projectDelete.php">Delete Project</a></h2>
                <p>You are editing project.</p>
            </div>

            <?php
            $link = Util::getLink();

            if (isset($_GET['textId'])) {

                $query = sprintf(Util::$select_jornakText,
                    mysql_real_escape_string($_GET['textId'])
                );

                $result = mysql_query($query);

                if (!$result) {
                    die('Could not query:' . mysql_error());
                }

                $row = mysql_fetch_assoc($result);

                $descPresent  = explode(';',$row['present']);

                $imageArray = explode(';', $row['imgs']);
                ?>
            <ul >

                <li id="li_1" >
                    <label class="description" for="element_1">Project name </label>
                    <div>
                        <input id="element_1" name="header" class="element text medium" type="text" maxlength="255" value="<?php echo stripslashes($row['header']);?>"/>
                    </div><p class="guidelines" id="guide_1"><small>Project name.</small></p>
                </li>		<li id="li_3" >
                    <label class="description" for="element_3">Long Text </label>
                    <div>
                        <textarea id="element_3" name="text" class="element textarea large"><?php echo stripslashes($row['text']);?></textarea>
                    </div><p class="guidelines" id="guide_3"><small>Details of the project.</small></p>
                </li>		<li id="li_4" >
                    <label class="description" for="element_4">Short Text </label>
                    <div>
                        <textarea id="element_4" name="list" class="element textarea small"><?php echo stripslashes($row['list']);?></textarea>
                    </div><p class="guidelines" id="guide_4"><small>Summary of details.</small></p>
                </li>		<li id="li_5" >
                    <label class="description" for="element_5">Flash video </label>
                    <div>
                        <input id="element_5" name="video" class="element text medium" type="text" maxlength="255" value="<?php echo stripslashes($row['video']); ?>"/>
                    </div> <p class="guidelines" id="guide_5"><small>Flash video. Upload it via ftp to www/admin/form/upload then write file name only. Example /File.jpg. (the file name is case sensitive)</small></p>
                </li>		<li id="li_20" >
                    <label class="description" for="element_20">Presentation label</label>
                    <div>
                        <input id="element_20" name="descPresent" class="element text medium" type="text" maxlength="255" value="<?php echo stripslashes($descPresent[1]); ?>"/>
                    </div> <p class="guidelines" id="guide_20"><small>Description of download. </small></p>
                </li>   <li id="li_6" >
                    <label class="description" for="element_6">Presentation </label>
                    <div>
                        <input id="element_6" name="present" class="element text medium" type="text" maxlength="255" value="<?php echo stripslashes($descPresent[0]); ?>"/>
                    </div> <p class="guidelines" id="guide_6"><small>Exe project presentation. Upload it via ftp to www/admin/form/upload then write file name only. Example /File.jpg. (the file name is case sensitive)</small></p>
                </li>		<li id="li_7" >
                    <label class="description" for="element_7">Image 1 </label>
                    <div>
                        <input id="element_7" name="img1" class="element file" type="file"/>
                    </div> <p class="guidelines" id="guide_7"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[0].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_8" >
                    <label class="description" for="element_8">Image 2 </label>
                    <div>
                        <input id="element_8" name="img2" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_8"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[2].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_9" >
                    <label class="description" for="element_9">Image 3 </label>
                    <div>
                        <input id="element_9" name="img3" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_9"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[4].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_10" >
                    <label class="description" for="element_10">Image 4 </label>
                    <div>
                        <input id="element_10" name="img4" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_10"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[6].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_11" >
                    <label class="description" for="element_11">Image 5 </label>
                    <div>
                        <input id="element_11" name="img5" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_11"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[8].'&tn=true" alt="" />' ?></small></p>
                </li><li id="li_12" >
                    <label class="description" for="element_12">Image 6 </label>
                    <div>
                        <input id="element_12" name="img6" class="element file" type="file"/>
                    </div> <p class="guidelines" id="guide_12"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[10].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_13" >
                    <label class="description" for="element_13">Image 7 </label>
                    <div>
                        <input id="element_13" name="img7" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_13"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[12].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_14" >
                    <label class="description" for="element_14">Image 8 </label>
                    <div>
                        <input id="element_14" name="img8" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_14"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[14].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_15" >
                    <label class="description" for="element_15">Image 9 </label>
                    <div>
                        <input id="element_15" name="img9" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_15"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[16].'&tn=true" alt="" />' ?></small></p>
                </li>		<li id="li_16" >
                    <label class="description" for="element_16">Image 10 </label>
                    <div>
                        <input id="element_16" name="img10" class="element file" type="file"/>
                    </div><p class="guidelines" id="guide_16"><small>Empty will use old image.<br/><br/><?php echo '<img src="../../Image.php?id='.$imageArray[18].'&tn=true" alt="" />' ?></small></p>
                </li>
                <li id="li_17" >
                    <label class="description" for="element_17">Visibility </label>
                    <div>
                        <input id="element_17_1" name="element_17_1" class="element checkbox" type="checkbox" value="visible" checked/><label class="choice" for="element_1_1">Visible</label>
                    </div><p class="guidelines" id="guide_17"><small>This property is always checked (default) even when the project was invisible. Make sure to change it to your desire. Check to make the project visible. </small></p>
                </li>

                <li class="buttons">
                    <input type="hidden" name="form_id" value="144190" />
                    <input type="hidden" name="textId" value="<?php echo stripslashes($_GET['textId']);?>" />
                    <input type="hidden" name="images" value="<?php echo stripslashes($row['imgs']);?>" />
                    <input type="hidden" name="videoHist" value="<?php echo stripslashes($row['video']);?>" />
                    <input type="hidden" name="exeHist" value="<?php echo stripslashes($row['present']);?>" />

                    <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
                </li>
            </ul>
            <input type="hidden" name="form_type" value="2" />
            <?

            }else {
                $query = sprintf(Util::$select_jornakDestinationAll,
                    mysql_real_escape_string('2')
                );
                $result = mysql_query($query);

                if (!$result) {
                    die('Could not query:' . mysql_error());
                }

                ?>
            <ul>
                <li id="li_1" >
                    <label class="description" for="element_1">Chose project</label>
                    <div>
                        <select class="element select medium" id="element_1" name="element_1">
                                <?php
                                $i = true;
                                while ($row = mysql_fetch_assoc($result)) {
                                    $query2 = sprintf(Util::$select_jornakText,
                                        mysql_real_escape_string($row['textid'])
                                    );

                                    $result2 = mysql_query($query2);

                                    if (!$result2) {
                                        die('Could not query:' . mysql_error());
                                    }
                                    $row2 = mysql_fetch_assoc($result2);

                                    if ($i) {
                                        echo ('<option value="'.$row['textid'].'" selected="selected">'.stripslashes($row2['header']).'</option>');
                                        $i = false;
                                    }else {
                                        echo ('<option value="'.$row['textid'].'">'.stripslashes($row2['header']).'</option>');
                                    }
                                }
                                ?>
                        </select>
                    </div><p class="guidelines" id="guide_1"><small>Your uploaded file will appear in chosed section.</small></p>
                </li>
                <li class="buttons">
                    <input type="hidden" name="form_id" value="144887" />

                    <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
                </li>
            </ul>
            <input type="hidden" name="choseSection" value="true" />
            <?php
            }
            if (isset($_GET['newsection'])) {
                echo '<input type="hidden" name="newSectionSecondStep" value="true" />';
            }
            Util::closeLink($link);

            ?>
        </form>
        <div id="footer">

        </div>
    </div>
    <img id="bottom" src="bottom.png" alt=""/>
</body>
</html>